Public Class PropertyGridEx
    Inherits PropertyGrid

    Private m_objToolStrip As ToolStrip

    Public Sub New()
        MyBase.New()
        Me.InitializeComponent()
    End Sub

    Public ReadOnly Property ToolStrip() As ToolStrip
        Get
            Return m_objToolStrip
        End Get
    End Property


    Private Sub PropertyGridEx_PropertySortChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PropertySortChanged
        If Me.PropertySort = Windows.Forms.PropertySort.CategorizedAlphabetical Then
            Me.PropertySort = Windows.Forms.PropertySort.Categorized
        End If
    End Sub


    Private Sub InitializeComponent()
        Dim objToolStripRenderer As New ToolStripProfessionalRenderer(New ProfessionalColorTable)

        objToolStripRenderer.RoundedEdges = False

        m_objToolStrip = CType(MyBase.GetType.BaseType.InvokeMember("toolStrip", System.Reflection.BindingFlags.NonPublic Or System.Reflection.BindingFlags.GetField Or System.Reflection.BindingFlags.Instance, Nothing, Me, Nothing), ToolStrip)
        m_objToolStrip.Renderer = objToolStripRenderer

        Me.PropertySort = Windows.Forms.PropertySort.Categorized
    End Sub

End Class
